<script type="text/html" template>
    <link rel="stylesheet" href="{{ layui.setter.base }}style/alert.css">
</script>
<style>
    .row .layui-form-label {
        width: 80px;
    }

    .row .layui-form-select .layui-input {
        padding-right: 0;
    }

    input::-webkit-outer-spin-button,
    input::-webkit-inner-spin-button {
        -webkit-appearance: none;
    }
 
    input[type="number"] {
        -moz-appearance: textfield;
    }
    .row .layui-input-block{
        line-height: 22px;
        height: 22px;
    }
</style>

<div class="layui-form row" lay-filter="layuiadmin-form-tags" id="layuiadmin-form-tags">
    <ul class="layui-row layui-form" lay-filter="layuiadmin-form-tags" id="layuiadmin-form-tags">
        <li class="layui-col-xs4 layui-col-sm4 layui-col-md4">


            <div class="flex layui-form-item">
                <label class="layui-form-label"><span style="font-size: 18px;color: red;position: relative;display: inline-block;line-height: 20px;vertical-align: middle;top:3px;">*</span>备品备件编号：</label>
                <div class="layui-input-block">

                    <select name="ima01" style="padding-right: 0;" lay-filter="selectTemplate" id="ima01"
                        placeholder="请输入备品备件编号" lay-search lay-verify="required">
                    </select>

                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label">备品备件名称：</label>
                <div class="layui-input-block">
                    <input type="text" id="beipiname" name="ima02" disabled autocomplete="off" class="layui-input" style="border: 0px;">
                </div>
            </div>



        </li>
        <li class="layui-col-xs4 layui-col-sm4 layui-col-md4" style="margin-left: 70px;">

            <div class="flex layui-form-item">
                <label class="layui-form-label"> 规格：</label>
                <div class="layui-input-block">
                    <input type="text" id="guige" name="ima021" disabled autocomplete="off" class="layui-input" style="border: 0px;">
                </div>
            </div>

            <div class="flex layui-form-item">
                <label class="layui-form-label"><span style="font-size: 18px;color: red;position: relative;display: inline-block;line-height: 20px;vertical-align: middle;top:3px;">*</span>调拨数量：</label>
                <div class="layui-input-block">
                    <input name="tcDetailNum" id="tcDetailNum" class="layui-input " value="" placeholder="请输入数量" autocomplete="off" type="number" required maxlength="11" onKeyUp="this.value=this.value.replace(/^(0+)|[^\d]+/g,'');this.value=this.value.replace('.','');"  lay-verify="required">
                </div>
            </div>
        </li>
    </ul>
    <input type="hidden" id="ima25" name="ima25">
    <div class="screen-footer layui-btn-container" style="text-align:center;margin-top: 60px;">
        <button class="layui-btn btn1 layui-btn-radius layui-btn-radius layui-btn-danger" lay-submit lay-filter="LAY-submit" style="margin-right: 40px;">确认</button>
        <button class="layui-btn btn2  layui-btn-radius layui-btn-radius" id="quxiao" style="background-color:#8A8A8A;">取消</button>
    </div>

</div>

<script>
    layui.use(['admin', 'form', 'api', 'table', 'laytpl', 'utill', 'laydate', 'treeSelect'], function () {
        var $ = layui.$,
            admin = layui.admin,
            view = layui.view,
            api = layui.api,
            table = layui.table,
            setter = layui.setter,
            jquery = layui.jquery,
            laydate = layui.laydate,
            form = layui.form;
        layer = layui.layer,
            util = layui.util,
            treeSelect = layui.treeSelect,
            $('.layui-form').on('click','#quxiao',function(){
                layer.closeAll()
            })
            form.on('select(selectTemplate)', function (data) {
                form.val('layuiadmin-form-tags',{
                    'ima021': data.value.split("/")[2]!=null&&data.value.split("/")[2] != 'null'?data.value.split("/")[2]: '',
                    'ima25': data.value.split("/")[3]!=null&&data.value.split("/")[3] != 'null'?data.value.split("/")[3]: '',
                    'ima02': data.value.split("/")[1]!=null&&data.value.split("/")[1] != 'null'?data.value.split("/")[1]: '',
                    'tcDetailNum': data.value.split("/")[4]!=null&&data.value.split("/")[4] != 'null'?data.value.split("/")[4]: '',
                })
                if(data.value.split("/")[4] != null && data.value.split("/")[4] != undefined && data.value.split("/")[4] != 'null'){
                    $('#tcDetailNum').data('id',data.value.split("/")[4]);
                }
                form.render(null, 'layuiadmin-form-tags');
            });
        admin.req({
            url: api.host + api.selectIma,
            data: {
                azp01: sessionStorage.getItem('tcReqCoalt')
            },
            done: function (res) {
                var str = '<option value=""></option>'
                for (let index = 0; index < res.data.length; index++) {
                    if(res.data.img10 != null){
                        str = str +
                        `<option value="${res.data[index].ima01}/${res.data[index].ima02}/${res.data[index].ima021}/${res.data[index].ima25}/${res.data[index].img10}">${res.data[index].ima01}</option>`
                    }
                    str = str +
                        `<option value="${res.data[index].ima01}/${res.data[index].ima02}/${res.data[index].ima021}/${res.data[index].ima25}" >${res.data[index].ima01}</option>`
                   
                }
                $('#ima01').append(str)
                form.render(null, 'layuiadmin-form-tags');
            }
        });
    });
</script>